/**
 * @(#)TestByteBuffer.java, Nov 26, 2012. 
 * 
 * Copyright 2012 Yodao, Inc. All rights reserved.
 * YODAO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.buaaer.net;

import java.nio.ByteBuffer;

/**
 *
 * @author wangheng
 *
 */
public class TestByteBuffer {

    /**
     * @param args
     */
    public static void main(String[] args) {

        ByteBuffer buffer = ByteBuffer.allocate(20);
        System.out.println(buffer.mark()+ " " + buffer.position() + " " + buffer.limit() + " " + buffer.capacity());
        buffer.put("hello".getBytes());
        buffer.flip();
        System.out.println(buffer.mark()+ " " + buffer.position() + " " + buffer.limit() + " " + buffer.capacity());
        buffer.put("world".getBytes());
        buffer.flip();
        System.out.println(buffer.mark()+ " " + buffer.position() + " " + buffer.limit() + " " + buffer.capacity());
        buffer.put("world".getBytes());
        
        System.out.println(buffer.mark()+ " " + buffer.position() + " " + buffer.limit() + " " + buffer.capacity());
        byte[] dst = buffer.array();
        
        String s = new String(dst);
        System.out.println(s);
    }

}
